<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
<!-- windows.qdoc -->
  <title>Qt for Windows - Building from Source | Qt 5.14</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td ><a href="index.html">Qt 5.14</a></td><td >Qt for Windows - Building from Source</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right">Qt 5.14.2 Reference Documentation</td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#step-1-install-the-license-file-commercially-licensed-qt-only">Step 1: Install the License File (Commercially Licensed Qt Only)</a></li>
<li class="level1"><a href="#step-2-unpack-the-archive">Step 2: Unpack the Archive</a></li>
<li class="level1"><a href="#step-3-set-the-environment-variables">Step 3: Set the Environment Variables</a></li>
<li class="level1"><a href="#step-4-build-the-qt-library">Step 4: Build the Qt Library</a></li>
<li class="level1"><a href="#parallel-builds">Parallel Builds</a></li>
<li class="level1"><a href="#step-5-build-the-qt-documentation">Step 5: Build the Qt Documentation</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">Qt for Windows - Building from Source</h1>
<span class="subtitle"></span>
<!-- $$$windows-building.html-description -->
<div class="descr"> <a name="details"></a>
<p>This page describes the process of configuring and building <a href="windows.html">Qt for Windows</a>. Before building, there are some requirements that are given in more detail in the <a href="windows-requirements.html">Qt for Windows - Requirements</a> document.</p>
<p>You can download the Qt 5 sources from the <a href="http://qt.io/download">Downloads</a> page. For more information, visit the <a href="gettingstarted.html">Getting Started with Qt</a> page.</p>
<a name="step-1-install-the-license-file-commercially-licensed-qt-only"></a>
<h2 id="step-1-install-the-license-file-commercially-licensed-qt-only">Step 1: Install the License File (Commercially Licensed Qt Only)</h2>
<p>If you use Qt with a commercial license, the Qt tools look for a local license file. If you are using a binary installer or the commercial Qt Creator, your licenses are automatically fetched and stored in your local user profile (<code>%USERPROFILE%\AppData\Roaming\Qt\qtlicenses.ini</code> file).</p>
<p>If you do not use any binary installer or Qt Creator, you can download the respective license file from your <a href="https://account.qt.io/">Qt Account</a> Web portal and save it to your user profile as <code>%USERPROFILE%\.qt-license</code>. If you prefer a different location or file name, you need to set the <code>QT_LICENSE_FILE</code> environment variable to the respective file path.</p>
<a name="step-2-unpack-the-archive"></a>
<h2 id="step-2-unpack-the-archive">Step 2: Unpack the Archive</h2>
<p>Uncompress the files into the directory you want Qt installed; e.g&#x2e; <code>C:\Qt\%VERSION%</code>.</p>
<p><b>Note: </b>The install path must not contain any spaces or Windows specific file system characters.</p><a name="step-3-set-the-environment-variables"></a>
<h2 id="step-3-set-the-environment-variables">Step 3: Set the Environment Variables</h2>
<p>We recommend creating a desktop link that opens a command prompt with the environment set up similar to the <b>Command Prompt</b> menu entries provided by Visual Studio. This is done by creating an application link passing a <code>.cmd</code> file setting up the environment and the command line option <code>/k</code> (remain open) to <code>cmd.exe</code>.</p>
<p>Assuming the file is called <code>qt5vars.cmd</code> and the Qt folder is called <code>Qt-5</code> and located under <code>C:\Qt</code>:</p>
<pre class="cpp plain">

  REM Set up Microsoft Visual Studio 2017, where &lt;arch&gt; is amd64, x86, etc.
  CALL &quot;C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Auxiliary\Build\vcvarsall.bat&quot; &lt;arch&gt;
  SET _ROOT=C:\Qt\Qt-5
  SET PATH=%_ROOT%\qtbase\bin;%_ROOT%\gnuwin32\bin;%PATH%
  REM Uncomment the below line when using a git checkout of the source repository
  REM SET PATH=%_ROOT%\qtrepotools\bin;%PATH%
  SET _ROOT=

</pre>
<p>A desktop link can then be created by specifying the command <code>%SystemRoot%\system32\cmd.exe /E:ON /V:ON /k C:\Qt\qt5vars.cmd</code> as application and <code>C:\Qt\Qt-5</code> as working directory.</p>
<p><b>Note: </b>Setups for <a href="https://mingw-w64.org/">MinGW</a> are similar; they differ only in that the <code>bin</code> folder of the installation should be added to the path instead of calling the Visual Studio setup script. For <a href="https://mingw-w64.org/">MinGW</a>, please make sure that no <code>sh.exe</code> can be found in the path, as it affects <code>mingw32-make</code>.</p><p>Settings required by the additional libraries (see <a href="windows-requirements.html">Qt for Windows - Requirements</a>) should also go this file below the call to the Windows SDK setup script.</p>
<a name="step-4-build-the-qt-library"></a>
<h2 id="step-4-build-the-qt-library">Step 4: Build the Qt Library</h2>
<p>The default behavior of configure is to create an in-source build of Qt 5. If you want to install Qt 5 to a separate location, you need to specify the command line option <code>-prefix &lt;location&gt;</code>. Alternatively, the command line option <code>-developer-build</code> creates an in-source build for developer usage.</p>
<p>To configure the Qt library for a debug build for your machine, type the following command in the command prompt:</p>
<pre class="cpp plain">

  configure -debug -nomake examples -nomake tests -skip qtwebengine -opensource

</pre>
<p>The <a href="configure-options.html">Configure Options</a> page contains more information about the configure options.</p>
<p>To build Qt using <a href="http://wiki.qt.io/jom">jom</a>, type:</p>
<pre class="cpp plain">

  jom

</pre>
<p>If you do not have <a href="http://wiki.qt.io/jom">jom</a> installed, type:</p>
<pre class="cpp plain">

  nmake

</pre>
<p>For <a href="https://mingw-w64.org/">MinGW</a>, type:</p>
<pre class="cpp plain">

  mingw32-make

</pre>
<p>If an installation prefix was given, type <code>jom install</code>, <code>nmake install</code> or <code>mingw32-make install</code>.</p>
<p><b>Note: </b>If you later need to reconfigure and rebuild Qt from the same location, ensure that all traces of the previous configuration are removed by entering the build directory and typing <code>nmake distclean</code> before running <code>configure</code> again.</p><a name="parallel-builds"></a>
<h2 id="parallel-builds">Parallel Builds</h2>
<p><a href="http://wiki.qt.io/jom">jom</a> is a replacement for <code>nmake</code> which makes use of all CPU cores and thus speeds up building.</p>
<a name="step-5-build-the-qt-documentation"></a>
<h2 id="step-5-build-the-qt-documentation">Step 5: Build the Qt Documentation</h2>
<p>For the Qt reference documentation to be available in <a href="../qtassistant/qtassistant-index.html">Qt Assistant</a>, you must build it separately:</p>
<pre class="cpp plain">

  nmake docs

</pre>
</div>
<!-- @@@windows-building.html -->
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2020 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br/>    The documentation provided herein is licensed under the terms of the    <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation    License version 1.3</a> as published by the Free Software Foundation.<br/>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>
